Sends a ray out from the camera along angle (degrees) and answers how far it goes, in pixels, before it meets a wall.
Game Boy: not available
Game Boy Color: not available
On other consoles this differs: see Side by side and How the consoles differ.
view3d_ray(angle) -> real| Name | Type |
|---|---|
angle | real |
real
Sends a ray out from the camera along angle (degrees) and answers how far it goes before it meets a wall, in pixels.
The ray goes through the same map the picture is drawn from, so it tells you what the screen would show along that angle. The room's edge is a wall, so there is always an answer. Where the ray met the wall waits in view3d_hit_x, view3d_hit_y and view3d_hit_wall until the next ray. A ray costs about as much as drawing one screen column.
// How much room is straight ahead?
var ahead = view3d_ray(view3d_angle());
if (ahead < 12) { view3d_turn(5); }The camera turns away when a wall is closer than 12 pixels ahead.
The ray is cast the same way the picture is, through the same map, so it answers what the screen would show along that angle. The room’s edge is a wall, so there is always an answer. Where it met the wall waits in view3d_hit_x, view3d_hit_y and view3d_hit_wall until the next ray. It costs about as much as one screen column.